﻿<UserControl x:Class="WpfFileExplorer.Views.FileView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:conv="clr-namespace:WpfFileExplorer.Converters"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <conv:EntityToColorConverter x:Key="EntityToColorConverter" />
    </UserControl.Resources>
    
    <ListView ItemsSource="{Binding Path=ParentFolder.Children}" 
                CommandEvent.EventName="MouseDoubleClick"
                CommandEvent.Command="{Binding Path=SelectItem}"
                CommandEvent.CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource Mode=Self}}"
                CommandEvent.AncestorType="{x:Type ListViewItem}" BorderThickness="0">
        <ListView.ItemContainerStyle>
            <Style TargetType="ListViewItem">
                <Setter Property="Foreground" Value="{Binding Converter={StaticResource EntityToColorConverter}}" />
                <Setter Property="BorderThickness" Value="0,0,1,.5" />
                <Setter Property="BorderBrush" Value="LightGray" />
            </Style>
        </ListView.ItemContainerStyle>
        <ListView.View>
            <GridView>
                <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Path=Name}" Width="250" />
                <GridViewColumn Header="Type" Width="80">
                    <GridViewColumn.DisplayMemberBinding>
                        <PriorityBinding>
                            <Binding Path="Extension" />
                        </PriorityBinding>
                    </GridViewColumn.DisplayMemberBinding>
                </GridViewColumn>
                <GridViewColumn Header="Size" Width="80">
                    <GridViewColumn.DisplayMemberBinding>
                        <PriorityBinding>
                            <Binding Path="FileSizeDescription" />
                        </PriorityBinding>
                    </GridViewColumn.DisplayMemberBinding>
                </GridViewColumn>
                <GridViewColumn Header="Date Modified" DisplayMemberBinding="{Binding Path=DateModified}" Width="130" />
            </GridView>
        </ListView.View>
    </ListView>
</UserControl>
